//
//  LinkmanNameCell.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/8/31.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

protocol LinkmanNameCellDelegate : NSObjectProtocol {
    func selectContactBtnDidTap()
}

class LinkmanNameCell: BaseTableViewCell {
    
    @IBOutlet weak var topTextField: UITextField!
    
    @IBOutlet weak var bottomTextField: UITextField!
    
    weak var delegate : LinkmanNameCellDelegate?
    
    
    var model : FillAddressInfoModel?{
        
        didSet{
            
            topTextField.text = model?.trueName
            
            bottomTextField.text = model?.phoneNumber
            
            
        }
        
        
        
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        
        topTextField.delegate = self

        bottomTextField.delegate = self

        // Initialization code
    }

    @IBAction func btnDidTap(_ sender: UIButton) {
        
        delegate?.selectContactBtnDidTap()
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}


extension LinkmanNameCell : UITextFieldDelegate{
    
    func textFieldDidEndEditing(_ textField: UITextField) {
        
        QL1("sdfsdfdsff")
        
        if textField ==  topTextField{
            
            model?.trueName = textField.text
            
        } else {
            
            model?.phoneNumber = textField.text
            
        }
        
        
    }
    
    
    
    
    
}
